 
  
* UPDATE using your own root folder
global mystart="/Users/faragons/Dropbox/yield_vs_tfo_project/CommentGollinUdry/empirics/REPLICATION FILES"



*install additional packages
{ 
	ssc install egenmore
 ssc install winsor
net install  "http://www.stata-journal.com/software/sj8-2/gr0034.pkg"
ssc install ivcrc
 ssc install outreg2
}


 
* Define file paths
{
global do = "${mystart}/Heterogeneity and Misallocation/do"
global allwave = "${mystart}/Heterogeneity and Misallocation/Data/LSMS Uganda"

global wave2009 = "${mystart}/Heterogeneity and Misallocation/Data/LSMS Uganda/UGA_2009_UNPS_v01_M_STATA"
global wave2010 = "${mystart}/Heterogeneity and Misallocation/Data/LSMS Uganda/UGA_2010_UNPS_v01_M_STATA"
global wave2011 = "${mystart}/Heterogeneity and Misallocation/Data/LSMS Uganda/UGA_2011_UNPS_v01_M_STATA"
global wave2013 = "${mystart}/Heterogeneity and Misallocation/Data/LSMS Uganda/UGA_2013_UNPS_v01_M_STATA8"
global megan = "${mystart}/Heterogeneity and Misallocation/Data/uganda input values"
global data = "${mystart}/Heterogeneity and Misallocation/Data/UgWorking"
global raindir = "${mystart}/Heterogeneity and Misallocation/Data"
global temp = "${mystart}/Heterogeneity and Misallocation/Data/UgWorking/Temp"
*global temp = "glu_temp"

// Note: The results are sent to __Working folders for testing:
global results = "${mystart}/Heterogeneity and Misallocation/Results/Uganda"
global ccresults = "${mystart}/Heterogeneity and Misallocation/Results/crosscountry"

 
*These are OUR folder
global FA_dofiles = "${mystart}/code"
global FA_datasets = "${mystart}/data"
global FA_results = "${mystart}/output"
}

  
 * STEP A . Prepare replication data (at plot-level) from Gollin and Udry (2021)
*---------------------------------------------------------
 {
 	//   You can omit this step. 
//  The replication file already contain the file  "data/data_TFP_UGA.dta"  and "data/data_TFP_TZ.dta"


//  cd "$FA_dofiles"
//  do "1_create_GU_UGA.do"
//   do "2_create_GU_TZ.do"
 }

 * STEP B. Prepare dataset of lan areas (9)parcel and farm level)
*-----------------------------------------------------------------------------------
 {
 	*You can omit this step. The replication file already contain the file  "$data/data_landarea.sta"

//  cd "$FA_dofiles"
//  do "3_create_data_landarea" //This creates data_landarea.dta, dataset at parcel level
 }
 
 
 
* STEP C. TABLE 1   (estimates of efficiency gains)
*-----------------------------------------------------------------------------------

cd "$FA_dofiles"
do "4_program_CalculateEfficiency.do" // Programs to calculage efficiency gains at plot and HH levels


do "5_table_1.do"


* STEP D. FIGURE 1   (distribution of land size , GPS vs self reported) 
*-----------------------------------------------------------------------------------

do "6_figure_2.do"



* STEP E. TABLE 2: Measurement error ( compare measuremetor erro with parcel vs farm level data)
*-----------------------------------------------------------------------------------


 do "7_table_error.do"
 
  
  
	 	 
* STEP F. repluca Bils et al (2021) error correction
*-----------------------------------------------------------------------------------

  
  do "8_table_BKR.do"
